package com.example.administrator.maizuofilm.customewidget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

/**
 * Created by hansen on 2016/7/13.
 */
public class MyRecyclerView extends RecyclerView {
    private GestureDetector detector;
    public MyRecyclerView(Context context) {
        super(context);
        init(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context);
    }
    private void init(Context context){
        detector=new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                Log.d("------------","-----------"+velocityX+"   "+velocityY);
                return velocityX>velocityY;
            }
        });
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {
        Log.d("------------","-----------"+detector.onTouchEvent(e));
        return true;
    }
}
